fetch(replaceHost(`http://www.kuwo.cn/api/www/music/musicInfo?mid=${location.search.split('=')[1]}&ip=&cip=&httpsStatus=1&reqId=55352fd0-ee65-11ed-bf96-b171a8c457de`)).then(res => res.json()).then((data) => {
    upMv(data)
})

fetch(replaceHost(`http://www.kuwo.cn/api/v1/www/music/playUrl?mid=${location.search.split("=")[1]}&type=mv&httpsStatus=1&reqId=d7649270-ee6a-11ed-82ef-2b19197a3856`)).then(res => res.json()).then((data) => {
    $("video").attr("src", data.data.url)
})

// 热门评论渲染函数
fetch(replaceHost(`http://www.kuwo.cn/comment?type=get_rec_comment&f=web&page=1&rows=5&digest=7&sid=${location.search.split("=")[1]}&uid=0&prod=newWeb&httpsStatus=1&reqId=c3475eb0-ee67-11ed-bcf6-bf9cb9020e3f`)).then(res => res.json()).then((data) => {
    hotRemark(data)
})

// 最新评论渲染函数
fetch(replaceHost(`http://www.kuwo.cn/comment?type=get_comment&f=web&page=1&rows=5&digest=7&sid=${location.search.split("=")[1]}&uid=0&prod=newWeb&httpsStatus=1&reqId=c3551a50-ee67-11ed-bcf6-bf9cb9020e3f`)).then(res => res.json()).then((data) => {
    upRemark(data)
})


function upMv(data) {
    $("video").attr("poster", data.data.albumpic)
    $(".tit").eq(0).html(data.data.name)
    $('.singer').eq(0).html(data.data.artist)
    $('.count').eq(0).html(`播放量：${data.data.mvPlayCnt}`)
    load()
}


// 热门评论渲染函数
function hotRemark(data) {
    $(`<h1>热门评论 <span class="msg4-count">${data.total ? data.total : 0}条</span></h1>`).appendTo($('.msg-4').eq(0))
    data.rows.forEach((v, i) => {
        $(`<div class="user-msg">
            <div class="pic">
                <img data-src=${v.u_pic} alt="">
            </div>
            <div class="text">
                <h5 class="tit">${v.u_name}</h5>
                <p>${v.msg}</p>
                <p class="time">
                   ${v.time}
                  </p>
            </div>
        </div>`).appendTo($('.msg-4').eq(0))
    })

    load()
}



// 最新评论渲染函数
function upRemark(data) {
    $(`<h1>最新评论 <span class="msg4-count">${data.total ? data.total : 0}条</span></h1>`).appendTo($('.msg-4').eq(1))
    data.rows.forEach((v, i) => {
        $(`<div class="user-msg">
            <div class="pic">
                <img data-src=${v.u_pic} alt="">
            </div>
            <div class="text">
                <h5 class="tit">${v.u_name}</h5>
                <p>${v.msg}</p>
                <p class="time">
                   ${v.time}
                  </p>
            </div>
        </div>`).appendTo($('.msg-4').eq(1))
    })
    load()
}



// 导航栏点击
$('.ku-nav > li').eq(0).on('click', function () {
    location.href = './index.html'
})

$('.ku-nav > li').eq(1).on('click', function () {
    location.href = './rankList.html'
})

$('.ku-nav > li').eq(2).on('click', function () {
    location.href = './singers.html'
})

$('.ku-nav > li').eq(3).on('click', function () {
    location.href = './playlists.html'
})

$('.ku-nav > li').eq(4).on('click', function () {
    location.href = './mvs.html'
})


$('.ku-logo').on('click', function () {
    location.href = './index.html'
})

// 懒加载
function load() {
    $("img").lazyload({
        threshold: -100, //临界值
        failure_limit: 0,
        event: "scroll",
        effect: "show",
        container: window,
        data_attribute: "src", // 存放真实地址data—
        skip_invisible: false,

        placeholder: "./img/loading.gif", // 显示的默认图片
    });
}